package com.szcinda.controller;

import com.szcinda.service.dto.orderFee.OperateDto;
import com.szcinda.service.dto.orderFee.OrderFeeService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("orderFee")
public class OrderFeeController {
    private final OrderFeeService orderFeeService;

    public OrderFeeController(OrderFeeService orderFeeService) {
        this.orderFeeService = orderFeeService;
    }

    @PostMapping("lockFee/{userId}")
    @OperationLogAnnotation(operDesc = "锁定费用", operModel = "")
    public Result<String> lockFee(@RequestBody OperateDto operateDto, @PathVariable String userId){
        orderFeeService.lockFee(operateDto.getIds(), userId, operateDto.getType(), operateDto.getFeeName());
        return Result.success();
    }

    @GetMapping("lockFee/{userId}/{feeId}")
    @OperationLogAnnotation(operDesc = "锁定费用", operModel = "")
    public Result<String> lockFee(@PathVariable String userId, @PathVariable String feeId){
        orderFeeService.lockFee(feeId, userId);
        return Result.success();
    }

    @GetMapping("unlockFee/{userId}/{feeId}")
    @OperationLogAnnotation(operDesc = "解锁费用", operModel = "")
    public Result<String> unlockFee(@PathVariable String userId, @PathVariable String feeId){
        orderFeeService.unlockFee(feeId, userId);
        return Result.success();
    }

    @PostMapping("unlockFee/{userId}")
    @OperationLogAnnotation(operDesc = "解锁费用", operModel = "")
    public Result<String> unlockFee(@RequestBody OperateDto operateDto, @PathVariable String userId){
        orderFeeService.unlockFee(operateDto.getIds(), userId, operateDto.getType(), operateDto.getFeeName());
        return Result.success();
    }

    @PostMapping("updateFee/{userId}")
    @OperationLogAnnotation(operDesc = "更新费用", operModel = "")
    public Result<String> updateFee(@RequestBody OperateDto operateDto, @PathVariable String userId){
        orderFeeService.updateFee(operateDto.getRowId(), userId, operateDto.getType(), operateDto.getFeeName(), operateDto.getFeeCount(), operateDto.getCurrency());
        return Result.success();
    }
}
